package com.shujia.flink.source

import org.apache.flink.streaming.api.scala._

object Demo2FileSource {
  def main(args: Array[String]): Unit = {
    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment


    /**
      * 2、基于文件构建DataStream --- 有界流
      *
      */
    val studentDS: DataStream[String] = env.readTextFile("data/students.txt")


    studentDS
      .map(_.split(",")(4))
      .map((_, 1))
      .keyBy(_._1)
      .sum(1)
      .print()


    env.execute()


  }

}
